<?php 
	/**
	* Auto-généré classe Service
	*/

	class Service extends \Core\ORM\Modele {
		/**
		* @var string $nom_service
		*/
		protected $nom_service;
        /**
		* @var string $description_service
		*/
		protected $description_service;
        
        
		/**
		* Constructeur complet
		*
		* @var int $id
		* @var string $nom_service
        * @var string $description_service
		*
		* @return void
		*/
		public function __construct($id, $nom_service, $description_service) {
			parent::__construct($id);
			$this->setNomService($nom_service);
            $this->setDescriptionService($description_service);
		}

        /**
        * Retourne le nom de ce Service
        * 
        * @return string
        */
        public function __toString() {
            return $this->nom_service;
        }
       
		//GETTERS ET SETTERS
		/**
		* Getter de l'attribut nom_service
		*
		* @return string
		*/
		public function getNomService() {
			return $this->nom_service;
		}
		/**
		* Setter de l'attribut nom_service
		*
		* @param string $nom_service		*
		* @return void
		*/
		public function setNomService($nom_service) {
			$this->nom_service=$nom_service;
		}
        /**
		* Getter de l'attribut description_service
		*
		* @return string
		*/
		public function getDescriptionService() {
			return $this->description_service;
		}
		/**
		* Setter de l'attribut description_service
		*
		* @param string $description_service
		* @return void
		*/
		public function setDescriptionService($description_service) {
			$this->description_service=$description_service;
		}
        
		public static function getAttributs() {
			return array(
							new Core\ORM\Attributs\String("nom_service", false, 30, false),
                            new Core\ORM\Attributs\String("description_service", false, 255, false)
						);
		}

		public static function getTable() {
			return "service";
		}
		
		public static function getServiceFromMachine(){
			$requete = new \Core\ORM\Requete\Select();
			$sql=   'SELECT COUNT(*) as nb, s.nom_service as nom, s.id as sId, s.description_service as descS
                   FROM machine m, service s 
                   WHERE m.service_id = s.id 
                   GROUP BY s.nom_service';
			$requete->setSql($sql);
			return $requete->execution();
		}
	}
?>